<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>小说管理后台</title>
    <link rel="stylesheet" href="../../static/admin/layui/css/layui.css" media="all"/>
    <link rel="stylesheet/less" href="../../../static/admin/css/index.less"/>
    <link rel="stylesheet" href="../../static/admin/css/jquery.pagination.css"/>
    <link rel="stylesheet/less" href="../../static/admin/css/user_redact.less"/>
    <script src="../../static/admin/js/jquery-1.12.3.js"></script>
    <script src="../../../static/admin/layui/layui.js"></script>
    <script src="../../static/admin/js/less.min.js"></script>
    <script src="../../static/admin/js/jquery.pagination.min.js"></script>
    <script src="../../../static/layer/layer.js"></script>

    <!--<script src="js/plugins/pace/pace.min.js"></script>-->
</head>
<style>
    .content img {
        width: 3rem;
    }

    img:hover {
        transform: scale(2, 2);
        transition: .5s transform;
    }

    .maskpsd1 {
        display: none;
        width: 100%;
        height: 100%;
        position: fixed;
        top: 0;
        left: 0;
        background-color: rgba(0, 0, 0, 0.4);
        z-index: 999;
    }

    .maskpsd1 .register {
        position: absolute;
        width: 40%;
        left: 30%;
        top: 25%;
        border: 1px solid #cccccc;
        border-radius: 8px;
        background-color: #fff;
    }

    .maskpsd1 .register ul {
        padding: 5px 20px 10px;
    }

    .maskpsd1 .register ul li {
        position: relative;
        padding: 5px 10px;
        border-bottom: 1px solid #ccc;
        min-height: 40px;
        line-height: 40px;
    }

    .maskpsd1 .register ul li h3 {
        display: inline-block;
        font-size: 18px;
        font-weight: bold;
        color: #666;
    }

    .maskpsd1 .register ul li .closeBtn1 {
        position: absolute;
        top: 0;
        right: 0;
        cursor: pointer;
    }

    .maskpsd1 .register ul li .regSpan {
        display: inline-block;
        width: 100px;
        text-align: left;
        margin-right: 10px;
    }

    .maskpsd1 .register ul li input[type=password] {
        width: 50%;
        height: 40px;
        line-height: 40px;
        border: 1px solid #A9A9A9;
        border-radius: 5px;
        background-color: #F7F7F7;
        font-size: 16px;
        padding-left: 10px;
        box-sizing: border-box;
    }

    .maskpsd1 .register ul li input[type=text] {
        width: 50%;
        height: 40px;
        line-height: 40px;
        border: 1px solid #A9A9A9;
        border-radius: 5px;
        background-color: #F7F7F7;
        font-size: 16px;
        padding-left: 10px;
        box-sizing: border-box;
    }

    {#    添加路由弹窗 #}
    .maskpsd2 {
        display: none;
        width: 100%;
        height: 100%;
        position: fixed;
        top: 0;
        left: 0;
        background-color: rgba(0, 0, 0, 0.4);
        z-index: 999;
    }

    .maskpsd2 .register {
        position: absolute;
        width: 40%;
        left: 30%;
        top: 25%;
        border: 1px solid #cccccc;
        border-radius: 8px;
        background-color: #fff;
    }

    .maskpsd2 .register ul {
        padding: 5px 20px 10px;
    }

    .maskpsd2 .register ul li {
        position: relative;
        padding: 5px 10px;
        border-bottom: 1px solid #ccc;
        min-height: 40px;
        line-height: 40px;
    }

    .maskpsd2 .register ul li h3 {
        display: inline-block;
        font-size: 18px;
        font-weight: bold;
        color: #666;
    }

    .maskpsd2 .register ul li .closeBtn1 {
        position: absolute;
        top: 0;
        right: 0;
        cursor: pointer;
    }

    .maskpsd2 .register ul li .regSpan {
        display: inline-block;
        width: 100px;
        text-align: left;
        margin-right: 10px;
    }

    .maskpsd2 .register ul li input[type=password] {
        width: 50%;
        height: 40px;
        line-height: 40px;
        border: 1px solid #A9A9A9;
        border-radius: 5px;
        background-color: #F7F7F7;
        font-size: 16px;
        padding-left: 10px;
        box-sizing: border-box;
    }

    .maskpsd2 .register ul li input[type=text] {
        width: 50%;
        height: 40px;
        line-height: 40px;
        border: 1px solid #A9A9A9;
        border-radius: 5px;
        background-color: #F7F7F7;
        font-size: 16px;
        padding-left: 10px;
        box-sizing: border-box;
    }
</style>

<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    {% include "/admin/left.html" %}
    <div class="layui-body">
{#        <div class="maskpsd1">#}
{#            <div class="register">#}
{#                <ul class="regBox">#}
{#                    <li>#}
{#                        <h3>添加管理员</h3>#}
{#                        <span class="add_xxx closeBtn1">关闭</span>#}
{#                    </li>#}
{#                    <li>#}
{#                        <span class="regSpan">请输入用户名</span>#}
{#                        <input type="text" title="" class="uname" id="add_username">#}
{#                    </li>#}
{#                    <li>#}
{#                        <span class="regSpan">请输入密码</span>#}
{#                        <input type="password" title="" class="uname" id="add_ps1">#}
{#                    </li>#}
{#                    <li>#}
{#                        <span class="regSpan">再次输入密码</span>#}
{#                        <input type="password" title="" class="uname" id="add_ps2">#}
{#                    </li>#}
{#                    <li>#}
{#                        <span class="regSpan">请选择账号类型</span>#}
{#                        <select id='admin_type'>#}
{#                        </select>#}
{#                    </li>#}
{#                    <li>#}
{#                        <span class="regSpan">备注</span>#}
{#                        <input type="text" title="" class="uname" id="admin_remark">#}
{#                    </li>#}
{#                    <li>#}
{#                        <button class="regUser1" id="add_tj">提交</button>#}
{#                    </li>#}
{#                </ul>#}
{#            </div>#}
{#        </div>#}
{#        <div class="maskpsd2">#}
{#            <div class="register">#}
{#                <ul class="regBox">#}
{#                    <li>#}
{#                        <h3>新增路由</h3>#}
{#                        <span class="add_xxx closeBtn1">关闭</span>#}
{#                    </li>#}
{#                    <li>#}
{#                        <span class="regSpan">路由名称</span>#}
{#                        <input type="text" title="" class="uname" id="link_name">#}
{#                    </li>#}
{#                    <li>#}
{#                        <span class="regSpan">路由地址</span>#}
{#                        <input type="text" title="" class="uname" id="link_address">#}
{#                    </li>#}
{##}
{#                    <li>#}
{#                        <button class="regUser1" onclick="add_links()" id="add_link">提交</button>#}
{#                    </li>#}
{#                </ul>#}
{#            </div>#}
{#        </div>#}
        <div id="box" class="fl">
            <div class="content">
                <h3>
                    版本列表
                    <button style="float: right; margin-right:1rem;font-size: 14px;" class="psd1"><a href="/admin/version/add.html">新增版本</a></button>
                </h3>


                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tbody>
                    <tr>
                        <th width="15%">版本名</th>
                        <th width="15%">版本号</th>
                        <th width="15%">下载链接</th>
                        <th width="15%">更新时间</th>
                        <th width="15%">状态</th>
                        <th width="15%">操作</th>
                    </tr>
                    </tbody>
                    {% if res['data'] is not none %}
                        {% for d in res['data'] %}
                            <tr>
                                <td>{{ d.version_num }}</td>
                                <td>{{ d.version_code }}</td>
                                <td>{{ d.url }}</td>
                                <td>{{ d.addTime }}</td>
                                <td>
                                    {% if d.status == 1 %}
                                        激活
                                    {% endif %}
                                    {% if d.status == 0 %}
                                        禁用
                                    {% endif %}
                                </td>
                                <td>
                                    {% if d.status == 0 %}
                                        <button>
                                            <a href="javascript:;" onclick="admin_update_start({{ d.id }})">激活</a>
                                        </button>
                                    {% endif %}
                                    {% if d.status == 1 %}
                                        <button>
                                            <a href="javascript:;" onclick="admin_update_stop({{ d.id }})">禁用</a>
                                        </button>
                                    {% endif %}

                                </td>
                            </tr>

                        {% endfor %}
                    {% endif %}
                </table>
            </div>
        </div>

    </div>
</div>

<script>
    //JavaScript代码区域
    layui.use('element', function () {
        var element = layui.element;

    });
</script>
</body>

</html>
<script src="../../static/admin/laydate/laydate.js"></script>
<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //常规用法
        laydate.render({
            elem: '#test1'
        });

        laydate.render({
            elem: '#test2'
        });
    })
     function admin_update_start(id){
        $.ajax({
                    type: 'post',
                    url: '/admin/version/start',
                    data: {
                        'id': id,
                    },
                    success: function (data) {
                        if (data.code==200) {
                            layer.msg("操作成功", {time: 2000}, function () {
                                window.location = '/admin/version/list.html'
                            });
                        } else {
                            layer.msg("操作失败", {time: 2000});
                        }
                    }
                });
    }

    function admin_update_stop(id){
        $.ajax({
                    type: 'post',
                    url: '/admin/version/stop',
                    data: {
                        'id': id,
                    },
                    success: function (data) {
                        if (data.code== 0) {
                            layer.msg("操作成功", {time: 2000}, function () {
                                window.location = '/admin/version/list.html'
                            });
                        } else {
                            layer.msg("操作失败", {time: 2000});
                        }
                    }
                });
    }

</script>
